<template>
	<view v-if="list" class="content">
		<view class="wid100" style="height: 394rpx;background: #3978F9;">
			<view class="wid90 mar dis disAl" style="height: 264rpx;">
				<view class="wid20">
					<image :src="list.avatarUrl" class="borRad50" style="width: 120rpx;height: 120rpx;"></image>
				</view>
				<view class="wid80 dis disAl disJuB coFFF">
					<view class="fowebl">
						<view class="foSi50 liH40">{{ list.nickname }}</view>
						<view class="mar-top20 foSi40">{{ list.tel }}</view>
					</view>
					<view style="display: flex;align-items: center;flex-direction: column;">
						<image src="../../static/imgs/icon/erwima.png" style="width: 50rpx;height: 50rpx;" @click="go_tk()"></image>
						<view class="" style="font-size: 24rpx;margin-top: 10rpx;">
							我要推广
						</view>
					</view>
					
					

				</view>
			</view>
			<view class="wid100 dis disAl coFFF" style="height: 130rpx;background-color: #2970FB;justify-content: space-around;">
				<view>
					<view class="foSi40 textCen liH40">{{ list.user_num }}</view>
					<view class="mar-top20 foSi25 textCen">推广好友</view>
				</view>
				<view>
					<view class="foSi40 textCen liH40">{{ list.user_integral }}</view>
					<view class="mar-top20 foSi25 textCen">获得积分</view>
				</view>
			</view>
		</view>
		<view class="hei20"></view>
		<view class="mar-top30 wid90 mar borRad20 bacFFF" style="padding: 30rpx 0;">
			<view class="wid90 mar">
				<view class="dis disAl disJuB">
					<view class="foSi40 fowebl">推广记录</view>
					<view class="dis disAl foSi20" style="color: #585858;" @click.stop="tiaozhuan(list.guize)">
						<image src="../../static/imgs/icon/tishi.png" style="width: 20rpx;height: 20rpx;"></image>
						<view class="mar-left10">推广规则</view>
					</view>
				</view>
				<view class="wid100 dis disAl disJuB foSi25 mar-top20" style="color: #585858;">
					<view class="textCen wid33">好友手机号</view>
					<view class="textCen wid33">状态</view>
					<view class="textCen wid33">奖励是否到账</view>
				</view>
				<scroll-view style="max-height: 800rpx;" class="wid100"
					scroll-y="true" @scrolltolower="lower">
					<view style="height: 1rpx;"></view>
					<view class="wid100 dis disAl disJuB foSi30 mar-top30 fowebl" v-for="(item,index) in recordList" :key="index">
						<view class="textCen wid33">{{ item.tel }}</view>
						<view class="textCen wid33" style="color: #035DFF;">已注册</view>
						<view class="textCen wid33">
							<span v-if="item.dz === 1" style="color: #035DFF;">已到账</span>
							<span v-if="item.dz === 0" style="color: #FE6522;">未完成</span>
						</view>
					</view>
					<view class="hei20"></view>
				</scroll-view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		User
	} from '../../model/user-model.js';
	var user = new User();
	export default {
		data() {
			return {
				list: null,
				recordList: []
			}
		},
		onLoad() {
			this.getList()
			this.getRecordlist()
		},
		onShow() {},
		methods: {
			go_tk(){
				var params = {}
				user.getuserid((data) => {
					console.log(data)
					if (data.code === 1) {
						uni.setStorageSync('tg_img',data.data.tg_img)
						uni.navigateTo({
							url:'/pages/user/promotion?pid='+data.data.uid
						})
					} else {
						uni.showToast({
							title: data.msg,
							icon: 'none',
							duration: 2000
						})
					}
				}, params)
				
			},
			getList(){
				var that = this
				let params = {}
				user.getPromotion((data) => {
					console.log(data)
					if (data.code === 0) {
						that.list = data.data
					} else {
						uni.showToast({
							title: data.msg,
							icon: 'none',
							duration: 2000
						})
					}
				}, params)
			},
			lower(e) {
				if(this.last_page > this.page){
					this.page++
					this.getRecordlist()
				}
			},
			getRecordlist(){
				var that = this
				let params = {
					page: that.page
				}
				user.getRecordlist((data) => {
					console.log(data)
					if (data.code === 0) {
						that.last_page = data.data.last_page
						that.recordList = that.page === 1?data.data.data:that.recordList.concat(data.data.data)
					} else {
						uni.showToast({
							title: data.msg,
							icon: 'none',
							duration: 2000
						})
					}
				}, params)
			},
			getCode(){
				var that = this
				let params = {}
				user.getCode((data) => {
					console.log(data)
					if (data.code === 0) {
						that.code = data.data
					} else {
						uni.showToast({
							title: data.msg,
							icon: 'none',
							duration: 2000
						})
					}
				}, params)
			},
			tiaozhuan(url) {
				uni.navigateTo({
					url: url
				});
			},
		}
	}
</script>

<style>
	.content {
		height: 100vh;
	}
	.xia{
		height: 1rpx;
		background: #D2D2D2;
	}
</style>
